<?php
    namespace app\api\model;
    use think\Exception;
    use think\Db;
    use think\Model;

    class Banner extends Model
    {
        protected $hidden = ['delete_time','update_time'];

        //关联模型
        public function items()
        {
            return $this->hasMany('BannerItem','banner_id','id');
        }
        // protected $table = 'banner_item';
        public static function getBannerById($id)
        {
            // $result = Db::query('select * from banner_item where banner_id=?',[$id]);
            $result = Db::table('banner_item')->where('banner_id','=',$id)->select();
            // 链式方法 select find update delete insert
            // where('字段名','表达式','条件')
             return $result;
        }
    }  